#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
const int inf = 0x3fffffff;
const int maxn = 1000002;
const int Logn = 20;
int N, M, f[maxn][Logn];
int main()
{
    scanf("%d%d", &N, &M);
    fill(f[0], f[0] + maxn * Logn, inf);
    for (int i = 1; i <= N; ++i)
    {
        scanf("%d", &f[i][0]);
    }
    for (int j = 1; j <= Logn; ++j)
    {
        for (int i = 1; i + (1 << j) - 1 <= N; ++i)
        {
            f[i][j] = min(f[i][j - 1], f[i + (1 << (j - 1))][j - 1]);
        }
    }
    for (int i = 1, k = log2(M); i + M - 1 <= N; ++i)
    {
        int l = i, r = i + M - 1;
        printf("%d\n", min(f[l][k], f[r - (1 << k) + 1][k]));
    }
    return 0;
}